from rest_framework_jwt.views import obtain_jwt_token
from django.conf.urls import url
from meiduo_admin.views.home_views import *
from rest_framework.routers import SimpleRouter
from meiduo_admin.views.user_views import *
from meiduo_admin.views.sku_views import *
from meiduo_admin.views.spu_views import *
from meiduo_admin.views.spec_views import *
from meiduo_admin.views.option_views import *
from meiduo_admin.views.channel_views import *
from meiduo_admin.views.brand_views import *
from meiduo_admin.views.images_views import *
from meiduo_admin.views.order_views import *
from meiduo_admin.views.permission_views import *
from meiduo_admin.views.usergroup_views import *
from meiduo_admin.views.admin_views import *

"""版本一"""

#
#
# urlpatterns = [
#     url(r'^authorizations/$', obtain_jwt_token),
#     url(r'^users/$', UserView.as_view()),
#     url(r'^skus/$', SKUViewSet.as_view()),
#     url(r'^skus/categories/$', GoodsGenericView.as_view()),
#     url(r'^goods/simple/$', SPUSimpleView.as_view()),
#     url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecView.as_view()),
#
#     url(r'^skus/(?P<pk>\d+)/$', SKUGoodsView.as_view()),
#
#     # SPU路由
#     url(r'^goods/$', SPUGoodsView.as_view()),
#     # 品牌
#     url(r'^goods/brands/simple/$', SPUBrandView.as_view()),
#     # spu一级分类
#     url(r'^goods/channel/categories/$', ChannelCategorysView.as_view()),
#     # 二三级分类
#     url(r'^goods/channel/categories/(?P<pk>\d+)/$', ChannelCategoryView.as_view()),
#     # 修改商品
#     url(r'^goods/(?P<pk>\d+)/$', SKUGoods_View.as_view()),
#
#     # 获取规格数据表
#     url(r'^goods/specs/$', SpecsView.as_view()),
#     # 获取规格单一数据
#     url(r'^goods/specs/(?P<pk>\d+)/$', SpecsSingleView.as_view()),
#
#     # 规格管理
#     url(r'^specs/options/$', OptionsView.as_view()),
#     # 添加规格
#     url(r'^goods/specs/simple/$', OptionSimple.as_view()),
#     # 查询单一规格
#     url(r'^specs/options/(?P<pk>\d+)/', OptionsOnlyView.as_view()),
#
#
#     # 频道管理
#     url(r'^goods/channels/$', ChannelView.as_view()),
#     # 一级分类
#     url(r'^goods/categories/$', ChannelClassifyView.as_view()),
#     # 频道组
#     url(r'^goods/channel_types/$', ChannelGroupView.as_view()),
#     # 获取单一数据
#     url(r'^goods/channels/(?P<pk>\d+)/$', ChannelGroupOnlyView.as_view()),
#
#     # 展示所有商品
#     url(r'^goods/brands/$', BrandView.as_view()),
#     # 获取单一数据
#     url(r'^goods/brands/(?P<pk>\d+)/$', BrandOnlyView.as_view()),
#
#     # 图片管理
#     url(r'^skus/images/$', ImagesView.as_view()),
#     # sku商品图片
#     url(r'^skus/simple/$', SKUSimpleView.as_view()),
#     # 获取单一图片数据
#     url(r'^skus/images/(?P<pk>\d+)/$', SKUImageSimpleView.as_view()),
#
#     # 订单
#     url(r'^orders/$', OrderView.as_view()),
#     # 订单详情
#     url(r'^orders/(?P<pk>\d+)/$', OrderParticularsView.as_view()),
#     # 修改订单
#     url(r'^orders/(?P<pk>\d+)/status/$', OrderParticularsView.as_view()),
#
#     # 权限管理
#     url(r'^permission/perms/$', PermissionView.as_view()),
#     # 权限类型
#     url(r'^permission/content_types/$', PermissionTypeView.as_view()),
#     # 获取单一数据
#     url(r'^permission/perms/(?P<pk>\d+)/$', PermissionOnlyView.as_view()),
#
#     # 获取所有用户组
#     url(r'^permission/groups/$', GroupsView.as_view()),
#     # 获取权限组
#     url(r'^permission/simple/$', GroupView.as_view()),
#     # 获取单一数据
#     url(r'^permission/groups/(?P<pk>\d+)/$', GroupOnlyView.as_view()),
#
#     # 获取所有管理员
#     url(r'^permission/admins/$', AdminView.as_view()),
#     # 管理员权限管理
#     url(r'^permission/groups/simple/$', AdminSimpleView.as_view()),
#     # 获取单一数据
#     url(r'^permission/admins/(?P<pk>\d+)/$', AdminObjView.as_view()),
#
# ]
#
#
# # 构建一个路由对象
# router = SimpleRouter()
# # statistical/total_count/
# # 注册路由  prefix=路劲前缀  viewset=视图集  base_name=随便指明一个
# router.register(prefix='statistical', viewset=HomeViewSet, base_name='home')
# urlpatterns += router.urls

"""版本二"""

urlpatterns = [
    url(r'^authorizations/$', obtain_jwt_token),
    url(r'^users/$', UserView.as_view()),

    url(r'^skus/categories/$', GoodsGenericView.as_view()),
    url(r'^goods/simple/$', SPUSimpleView.as_view()),
    url(r'^skus/$', SKUViewSet.as_view()),
    url(r'^goods/(?P<pk>\d+)/specs/$', SPUSpecView.as_view()),
    url(r'^skus/(?P<pk>\d+)/$', SKUGoodsView.as_view()),

    # SPU路由
    url(r'^goods/$', SPUGoodsView.as_view()),
    # 品牌
    url(r'^goods/brands/simple/$', SPUBrandView.as_view()),
    # spu一级分类
    url(r'^goods/channel/categories/$', ChannelCategorysView.as_view()),
    # 二三级分类
    url(r'^goods/channel/categories/(?P<pk>\d+)/$', ChannelCategoryView.as_view()),
    # 修改商品
    url(r'^goods/(?P<pk>\d+)/$', SKUGoods_View.as_view()),

    # 获取规格数据表
    url(r'^goods/specs/$', SpecsView.as_view()),
    # 获取规格单一数据
    url(r'^goods/specs/(?P<pk>\d+)/$', SpecsSingleView.as_view()),

    # 规格管理
    url(r'^specs/options/$', OptionsView.as_view()),
    # 添加规格
    url(r'^goods/specs/simple/$', OptionSimple.as_view()),
    # 查询单一规格
    url(r'^specs/options/(?P<pk>\d+)/', OptionsOnlyView.as_view()),

    # 频道管理
    url(r'^goods/channels/$', ChannelView.as_view()),
    # 一级分类
    url(r'^goods/categories/$', ChannelClassifyView.as_view()),
    # 频道组
    url(r'^goods/channel_types/$', ChannelGroupView.as_view()),
    # 获取单一数据
    url(r'^goods/channels/(?P<pk>\d+)/$', ChannelGroupOnlyView.as_view()),

    # 展示所有商品
    url(r'^goods/brands/$', BrandView.as_view()),
    # 获取单一数据
    url(r'^goods/brands/(?P<pk>\d+)/$', BrandOnlyView.as_view()),

    # 图片管理
    url(r'^skus/images/$', ImagesView.as_view({'get': 'list', 'post': 'create'})),
    # sku商品图片
    url(r'^skus/simple/$', SKUSimpleView.as_view()),
    # 获取单一图片数据
    url(r'^skus/images/(?P<pk>\d+)/$', ImagesView.as_view({'get': 'retrieve',
                                                           'put': 'update',
                                                           'delete': 'destroy'})),

    # 订单
    url(r'^orders/$', OrderView.as_view()),
    # 订单详情
    url(r'^orders/(?P<pk>\d+)/$', OrderParticularsView.as_view()),
    # # 修改订单
    url(r'^orders/(?P<pk>\d+)/status/$', OrderParticularsView.as_view()),

    # 权限类型
    url(r'^permission/content_types/$', PermissionTypeView.as_view()),

    # 获取权限组
    url(r'^permission/simple/$', GroupView.as_view()),

    # 管理员权限管理
    url(r'^permission/groups/simple/$', AdminSimpleView.as_view()),

]

# 构建一个路由对象
router = SimpleRouter()
# statistical/total_count/
# 注册路由  prefix=路劲前缀  viewset=视图集  base_name=随便指明一个
router.register(prefix='statistical', viewset=HomeViewSet, base_name='home')

# 权限管理
router.register(prefix='permission/perms', viewset=PermissionView, base_name='permission')

# 获取所有用户组
router.register(prefix='permission/groups', viewset=GroupsView, base_name='groups')

# 获取所有管理员
router.register(prefix='permission/admins', viewset=AdminView, base_name='admin')

urlpatterns += router.urls
